package com.learn.thread;

import lombok.SneakyThrows;

public class TestThreadState implements Runnable{
    @SneakyThrows
    @Override
    public void run() {
        Thread.sleep(100);
        System.out.println("子线程结束");
    }

    public static void main(String[] args) {
        TestThreadState testThreadState = new TestThreadState();
        Thread thread = new Thread(testThreadState);
        System.out.println(thread.getState().name());//New
        thread.start();
        System.out.println(thread.getState().name());//Runnable
        while (thread.getState() != Thread.State.TERMINATED){
            System.out.println(thread.getState().name());//TIMED_WAITING
        }

        System.out.println(thread.getState().name());//terminated
    }
}
